package com.thomas.framework.web.interceptor;

import com.thomas.framework.utils.PageResult;
import org.apache.log4j.Logger;
import org.aspectj.lang.ProceedingJoinPoint;

/**
 * 异常处理类
 * Created by taohj on 2014/5/24.
 */
public class ExceptionHandlerAdapter {

    Logger logger = Logger.getLogger(this.getClass());

    public Object invoke(ProceedingJoinPoint obj) throws Throwable {

        PageResult pageResult = new PageResult();

        try {
            return obj.proceed();
        } catch (Throwable e) {
            e.printStackTrace();
            logger.error("Log Exceiption:" + e.getMessage());
            pageResult.setSuccess(false);
            pageResult.setMessage(e.getMessage());
        }

        return pageResult.toString();
    }


}
